package br.gov.dataprev.treinamento.ejb.modelo;


import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@DiscriminatorValue("PJ")
@Table(name="PESSOAS_JURIDICAS", uniqueConstraints={@UniqueConstraint(columnNames={"NU_CNPJ"})})
public class PessoaJuridica extends Cliente {
	
	private static final long serialVersionUID = 1L;

	@Column(name="NU_CNPJ", length=14)
	private String cnpj;
	
	@Column(name="NO_RAZAO_SOCIAL", length=100)
	private String razaoSocial;

	public PessoaJuridica() {
		super();
		// TODO Auto-generated constructor stub
	}

	public String getCnpj() {
		return cnpj;
	}

	public void setCnpj(String cnpj) {
		this.cnpj = cnpj;
	}

	public String getRazaoSocial() {
		return razaoSocial;
	}

	public void setRazaoSocial(String razaoSocial) {
		this.razaoSocial = razaoSocial;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((cnpj == null) ? 0 : cnpj.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (!(obj instanceof PessoaJuridica))
			return false;
		PessoaJuridica other = (PessoaJuridica) obj;
		if (cnpj == null) {
			if (other.cnpj != null)
				return false;
		} else if (!cnpj.equals(other.cnpj))
			return false;
		return true;
	}
	
}
